package cn.gok.service.impl;

import cn.gok.entity.Bug;
import cn.gok.mapper.BugMapper;
import com.alibaba.fastjson.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class BugServiceImpl implements cn.gok.service.BugService{
    @Autowired(required = false)
    private BugMapper bugMapper;
    //添加
    @Override
    public int add(Map<String, Object> map) {
        return bugMapper.add(map);
    }
    //删除
    @Override
    public int del(Map<String,Object> map) {
        return bugMapper.del(map);
    }
    //修改
    @Override
    public int updata(Map<String, Object> map) {
        return bugMapper.updata(map);
    }

    @Override
    public List<Bug> sel(Map<String, Object> map) {
        return null;
    }

    @Override
    public List<Bug> show(Map<String, Object> map) {
        return bugMapper.show(map);
    }

    @Override
    public List<Bug> details(Map<String, Object> map) {
        return bugMapper.details(map);
    }

    public List<Bug> show1(Map<String, Object> map) {
        return bugMapper.show1(map);
    }

    @Override
    public List<Bug> my(Map<String, Object> map) {
        return bugMapper.my(map);
    }

    @Override
    public List<Bug> show2() {
        return bugMapper.show2();
    }

    @Override
    public int re(Map<String, Object> map) {
        return bugMapper.re(map);
    }

    @Override
    public int re3(Map<String, Object> map) {
        return bugMapper.re3(map);
    }

    @Override
    public int re4(Map<String, Object> map) {
        return bugMapper.re4(map);
    }

    public int updata1(Map<String, Object> map) {
        return bugMapper.updata1(map);
    }
    public int updata2(Map<String, Object> map) {
        JSONArray ids=(JSONArray) map.get("ids");
        Map<String,Object> map1=new HashMap<>();
        map1.put("userid",map.get("id"));
        map1.put("user",map.get("name"));
        for (int i=0;i<ids.size();i++){
            int id= (int) ids.get(i);
            map1.put("id",id);
            bugMapper.updata2(map1);
        }
        return ids.size();
    }
}
